package fr.bull.learn.thread.chat;

/**
 * T2 le Titou de premiere classes
 * @author Rouviere-X
 *
 */
public class Titou implements Runnable {
    private Chat c;
    private String[] messages;
    private String name;
    
    public Titou(Chat c, String name,  String[] messages) {
        this.c = c;
        this.messages = messages;
        this.name = name; 
        new Thread(this, name).start();
    }

    public void run() {
        for (int i = 0; i < messages.length; i++) {
            if (name.equalsIgnoreCase("question")) {
            	c.question(messages[i]);
            } else {
            	c.answer(messages[i]);
            }
        }
    }
}